package com.kcl.dfss.adapter;

import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.kcl.dfss.R;

public class AccountAdapter extends BaseAdapter {
	
	private List<HashMap<String, String>> list;
	private Context context;
	private int type[];
	
	public AccountAdapter(List<HashMap<String, String>> list,Context context,int type[]) {
		this.list = list;
		this.context = context;
		this.type = type;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater mInflater = LayoutInflater.from(context);
		View view = null;
		if(type[position]==0){
			view = mInflater.inflate(R.layout.account_item01, null);
			String content = list.get(position).get("data");
			String items[] = content.split(",");
			TextView text1 = (TextView) view.findViewById(R.id.text1);
			TextView text2 = (TextView) view.findViewById(R.id.text2);
			if(items.length == 1){
				text1.setText(items[0]);
				text2.setText(" ");
			}else{
				text1.setText(items[0]);
				text2.setText(items[1]);
			}
			
		}else{
			view = mInflater.inflate(R.layout.account_item02, null);
			String name1 = list.get(position).get("data");
			TextView text3 = (TextView) view.findViewById(R.id.text3);
			ImageView image = (ImageView) view.findViewById(R.id.image1);
			if(name1.equals("头像编辑")){
				image.setImageResource(R.drawable.arrow_right);
			}else if(name1.equals("修改密码")){
				image.setImageResource(R.drawable.arrow_right);
			}
			text3.setText(name1);
		}
		return view;
	}
}
